<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>get/delete发送请求</title>
</head>

<body>
  <script>

    // 传统 URL 传参
    // 第一个参数是地址，第二个参数是一个对象
    fetch('http://localhost:3000/books?id=4', {
      method: 'get'
    }).then((data) => {
      return data.text()
    }).then((data) => {
      console.log(data)
    })

    // restFull 接口规范
    fetch('http://localhost:3000/books/4', {
      method: 'get'
    }).then((data) => {
      return data.text()
    }).then((data) => {
      console.log(data)
    })

    // delete 请求
    // restFull 接口规范只和请求的方式有关，和请求地址无关
    fetch('http://localhost:3000/books/4', {
      method: 'delete'
    }).then((data) => {
      return data.text()
    }).then((data) => {
      console.log(data)
    })
  </script>
</body>

</html>